/*
 * semaphores.h
 *
 *  Created on: 28/set/2014
 *      Author: root
 */

#ifndef SEMAPHORES_H_


#define SEMAPHORES_H_
#include <stdio.h>
#include <sys/ipc.h>
#include <sys/sem.h>
#include <sys/types.h>
//#include "errors.h"

#define USR_IN_OUT_SEM_LIST 2677
int usrInOutSemId;


typedef union semun{
	int val;
	struct semid_ds *buf;
	unsigned short int *array;
	struct seminfo * __buf;
}SEMUN;

typedef struct mBoxSem{
	int mBoxSemId;
	char * usr;
}MBXSEM;
typedef MBXSEM * PMBXSEM;
typedef PMBXSEM * PPMBXSEM;

int binSemAlloc(key_t, int);
int binSemDeAlloc(int);
int binSemInit(int);
int binSemWait(int);
int binSemPost(int);
void initMBoxSems(char *, int);
int getMBoxSem(char *);
void freeMBoxSems();





#endif /* SEMAPHORES_H_ */
